package com.example.springdemo.domain.bean_life;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.support.DefaultSingletonBeanRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

//@Component("kk-student")
public class Student implements BeanFactoryAware, BeanNameAware, EnvironmentAware, InitializingBean, DisposableBean {

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("kk-stu = " + beanFactory.containsBean("kk-stu-1"));
    }

    @Override
    public void setBeanName(String name) {
        System.out.println("name = " + name);
    }

    @Override
    public void setEnvironment(Environment environment) {
        System.out.println("environment.getProperty(\"service.name\") = " + environment.getProperty("service.name"));
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("destroy");
    }
}

















